<title>分类管理</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>问答管理</cite></a>
    <a><cite>分类管理</cite></a>
  </div>
</div>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
        
          <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief" lay-filter="J_tabLi_category">
              <ul class="layui-tab-title">
                <li{if $type eq 'question'} class="layui-this"{/if}><a lay-href="wendasns/category/index?type=question">问答</a></li>
                <li{if $type eq 'article'} class="layui-this"{/if}><a lay-href="wendasns/category/index?type=article">文章</a></li>
              </ul>
              <div class="layui-tab-content">
              	<div class="layui-tab-item layui-show"></div>
              </div>
            </div>
          </div>
          
        <div class="layui-card-body">
    
      <div style="padding-bottom: 10px;">
        <a href="#J_view" class="layui-btn J_popup" title="添加分类" data-type="{$type}"><i class="layui-icon layui-icon-add-circle"></i>添加</a>
        <a href="wendasns/category/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
      </div>
      
      <table id="J_table_list" lay-filter="J_table_list" url="{:url('wendasns/category/edit')}"></table>
    </div>
    
      </div>
    </div>
  </div>
</div>

<script type="text/html" id="J_checkbox_tpl">
  <input type="checkbox" name="status" lay-skin="switch" lay-text="是|否" lay-filter="J_checkbox_enable" value="{{ d.id }}" {{ d.status == 1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="J_table_tool">
  <a href="#J_view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑分类"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  <a href="wendasns/category/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>

<script>
;!function(){
  var $ = layui.$
  ,table = layui.table;
  
  //执行渲染
table.render({
  elem: '#J_table_list'
  ,url: '{:url('wendasns/category/list',['type'=>$type])}'
  ,cols: [[
      {type: 'checkbox'}
      ,{field:'id',title:'ID',width:100,align:'center'}
      ,{field:'name',title:'分类名称',minWidth:100,edit:'text'}
      ,{field:'dir_name',title:'目录名称',minWidth:100,edit:'text'}
      ,{field:'icon',title:'图标',width:100,align:'center',templet:'<div><i class="layui-icon {{d.icon}}"></i></div>'}
      ,{field:'status',title:'启用',width:120,templet:'#J_checkbox_tpl',align:'center'}
      ,{title:'操作',width:150,align:'center',toolbar:'#J_table_tool'}
  ]]
  ,page: true
  ,limit: 20
  ,height: 'auto'
  ,text: {
    none: '暂无数据！'
  }
});

}();
</script>

<script type="text/html" id="J_view">
  <form class="layui-form" action="{:url('wendasns/category/dorun')}" method="post">
    <input type="hidden" name="id" value="{{d.id||0}}">
    <input type="hidden" name="type" value="{{d.type||''}}">

            <div class="layui-form-item">
              <label class="layui-form-label">分类名称</label>
              <div class="layui-input-inline">
                <input type="text" name="name" value="{{d.name||''}}" lay-verify="required" class="layui-input">
              </div>
            </div>
            
            <div class="layui-form-item">
              <label class="layui-form-label">目录名称</label>
              <div class="layui-input-inline">
                <input type="text" name="dir_name" value="{{d.dir_name||''}}" lay-verify="required" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">必须是英文字母</div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">图标</label>
              <div class="layui-input-inline">
                <input type="text" name="icon" value="{{d.icon||''}}" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">支持html代码</div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">启用</label>
              <div class="layui-input-inline">
                <input type="radio" name="status" value="1" title="是" {{ d.status === 1 ? 'checked="checked"' : (typeof d.status==='undefined'&&'checked') }}>
                <input type="radio" name="status" value="0" title="否" {{ d.status === 0 ? 'checked="checked"' : '' }}>
              </div>
            </div>
            
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
              </div>
            </div>
          </form>
</script>